<?php 
	$data = $_GET['data'];
	$jenis = $_GET['jenis'];
	include ('../../../config/koneksi.php'); 
	include ('../../../config/library.php');
	include ('../../../config/fungsi_tgl_indo.php');
	$qry = mysql_query("select p.id_penduduk,id_peserta,nik,nama,jk,tempat_lahir,tgl_lahir,pekerjaan,jkn,is_miskin,bpjs,masa_berlaku from penduduk p inner join pekerjaan pr on p.id_pekerjaan = pr.id_pekerjaan left join peserta ps on p.id_penduduk = ps.id_penduduk where $jenis like '%$_GET[data]%' group by id_penduduk");

	$ketemu=mysql_num_rows($qry);
	$now = date("Y-m-d");
	if($ketemu >= 0) {
?>
		<table class="tabel">
			<tr>
				<th>NO</th>
				<th>Aksi</th>
				<th>NIK</th>
				<th>Nama</th>
				<th>JK</th>
				<th>Tempat, Tanggal Lahir</th>
				<th>Pekerjaan</th>
				<th>Status</th>
				<th>BPJS</th>
			</tr>
<?php
		while($hasil=mysql_fetch_array($qry)){
		$no++;
?>
			<tr>
				<td align="center" width="30"><?php echo $no;?></td>
				<td align="center" width="60">
					<?php 
						if($hasil['id_peserta'] != '' && $hasil['masa_berlaku'] >= $now){ 
							echo "<img src=asset/images/daftar.png title='Sudah Terdaftar'>"; 
						}else{
							?>
								<a href="utama.php?module=mod_peserta&view=form_tambah&id=<?php echo $hasil['id_penduduk'];?>" onclick="return confirm('Calon Peserta Terdaftar Sebagai Peserta BPJS, apakah akan didaftarkan ?')"> <img src="asset/images/add.png" title="Tambah Sebagai Peserta"></a>
							<?php
						}
					?> 
				</td>
				<td align="center" width="60"><?php echo $hasil['nik'];?></td>
				<td ><?php echo $hasil['nama'];?></td>
				<td ><?php echo $hasil['jk'];?></td>
				<td ><?php echo $hasil['tempat_lahir'].", ".tgl_ind1("$hasil[tgl_lahir]");?></td>
				<td ><?php echo $hasil['pekerjaan'];?></td>
				<td >
					<?php 
						if($hasil['is_miskin'] == 'Y'){
							echo "Miskin";
						}else{
							echo "Tidak Miskin";
						}
					?>
				</td>
				<td align="center">
					<?php 
						if($hasil['bpjs'] == 'Y'){
							echo "Ya";
						}else{
							echo "Tidak";
						}
					?>
				</td>
			</tr>	
<?php
		}
		echo "</table>";
	}else{
?>
	<script>
		$(document).ready(function(){
		  $("#hide").click(function(){
			$("#form").hide();
		  });
		  $("#show").click(function(){
			$("#form").show();
		  });
		  $("#form").hide();
		  
		  $(function() {
			$( "#datepicker1" ).datepicker();
		  });
		});
	</script>
	<script type="text/javascript" src="module/mod_peserta/js/combo.js"></script>
		<button class="button" id="show" style="margin-left:10px;">Tambah KK</button>
		<button class="button" id="hide">Batal</button>
		
		<form action="utama.php?module=mod_peserta&act=simpan" onsubmit="return gsValidate('nik','NIK Harus Diisi','required');" method="post" enctype="multipart/form-data">
			<div id="form">
				<table style="margin: 10px 15px 10px 15px;">
					<tr>
						<td width="125">ID KK</td>
						<td>
							<input name="kode" type="text" id="kode" class="input2" />
						</td>
					</tr>
					<tr>
						<td>Alamat</td>
						<td>
							<input name="alamat" type="text" class="input" id="alamat" maxlength="255"/>
						</td>
					</tr>
					<tr>
						<td>RT</td>
						<td>
							<input name="rt" type="text" class="input_small" id="rt" maxlength="5"/>
						</td>
					</tr>
					<tr>
						<td>RW</td>
						<td>
							<input name="rw" type="text" class="input_small" id="rw" maxlength="5"/>
						</td>
					</tr>
					<tr>
						<td>Provinsi</td>
						<td>
							<select name="provinsi" id="provinsi" class="input2">
								<?php
									$provinsi = mysql_query("select * from propinsi order by propinsi");
									while($p = mysql_fetch_array($provinsi)){
										if($p['id_propinsi']=='64'){
											$s = "selected";
										}else{
											$s = "";
										}
										echo "<option value='$p[id_propinsi]' $s>$p[propinsi]</option>";
									}
								?>
							</select>
						</td>
					</tr>
					<tr>
						<td>Kabupaten</td>
						<td>
							<select name="kabupaten" id="kabupaten" class="input2">
								<?php
									$kabupaten = mysql_query("select * from kabupaten where id_propinsi='64' order by kabupaten");
									while($k = mysql_fetch_array($kabupaten)){
										if($k['id_kabupaten']=='6405'){
											$s = "selected";
										}else{
											$s = "";
										}
										echo "<option value='$k[id_kabupaten]' $s>$k[kabupaten]</option>";
									}
								?>
							</select>
						</td>
					</tr>
					<tr>
						<td>Kecamatan</td>
						<td>
							<select name="kecamatan" id="kecamatan" class="input2">
								<option value=''> - - Pilih Kecamatan - - </option>
								<?php
									$kecamatan = mysql_query("select * from kecamatan where id_kabupaten='6405' order by kecamatan");
									while($kc = mysql_fetch_array($kecamatan)){
										echo "<option value='$kc[id_kecamatan]'>$kc[kecamatan]</option>";
									}
								?>
							</select>
						</td>
					</tr>
					<tr>
						<td>Desa</td>
						<td>
							<select name="desa" id="desa" class="input2">
								<option value=''> - - Pilih Desa - - </option>
							</select>
						</td>
					</tr>
					<tr>
						<td>Dikeluarkan</td>
						<td><input name="tgl_keluar" type="text" id="datepicker1" class="input2"/></td>
					</tr>
				</table>
			</div>
			<table style="margin: 10px 15px 10px 15px;">
				<tr>
					<td width="125">NIK</td>
					<td width="320">
						<input name="nik" type="text" id="nik" class="input2"/>
					</td>
					<td width="125">Agama</td>
					<td>
						<?php buat_kombo("agama","agama","input2","id_agama"); ?>
					</td>
				</tr>
				<tr>
					<td>Nama</td>
					<td>
						<input name="nama" type="text" id="nama" class="input2"/>
					</td>
					<td>Pendidikan</td>
					<td>
						<?php buat_kombo("pendidikan","pendidikan","input2","id_pendidikan"); ?>
					</td>
				</tr>
				<tr>
					<td>Jenis Kelamin</td>
					<td>
						<select name="jk" type="text" id="jk" class="input2">
							<option value='L' selected>Laki-laki</option>
							<option value='P' >Perempuan</option>";
						</select>
					</td>
					<td>Pekerjaan</td>
					<td>
						<?php buat_kombo("pekerjaan","pekerjaan","input2","id_pekerjaan"); ?>
					</td>
				</tr>
				<tr>
					<td>Tempat Lahir</td>
					<td>
						<input name="tempat_lahir" type="text" id="tempat_lahir" class="input2"/>
					</td>
					<td>Status</td>
					<td>
						<?php buat_kombo("status_nikah","status","input2","id_status");?>
					</td>
				</tr>
				<tr>
					<td>Tanggal Lahir</td>
					<td>
						<select name="tgl" id="tgl" class="input1">
							<option value="">Tgl</option>
							<?php
								for($i=1;$i<=31;$i++){
									echo "<option value=$i>$i</option>";
								}
							?>
						</select>
						<select name="bln" id="bln" class="input1">
							<option value="">Bln</option>
							<?php
								for($i=1;$i<=12;$i++){
									echo "<option value=$i>$i</option>";
								}
							?>
						</select>
						<select name="thn" id="thn" class="input1">
							<option value="">Tahun</option>
							<?php
								for($i=1900;$i<=2020;$i++){
									echo "<option value=$i>$i</option>";
								}
							?>
						</select>
					</td>
					<td>Hubungan Keluarga</td>
					<td>
						<?php buat_kombo("hub_keluarga","keluarga","input2","id_hub_keluarga"); ?>
					</td>
				</tr>
				<tr>
					<td>Kewarganegaraan</td>
					<td>
						<select name="kewarganegaraan" id="kewarganegaraan" class="input2">
							<option value='WNI' selected>WNI</option>
							<option value='WNA'>WNA</option>";
						</select>
					</td>
					<td>Ayah</td>
					<td>
						<input name="ayah" type="text" id="ayah" class="input2"/>
					</td>
				</tr>
				<tr>
					<td>No Paspor</td>
					<td>
						<input name="paspor" type="text" id="paspor" class="input2"/>
					</td>
					<td>Ibu</td>
					<td>
						<input name="ibu" type="text" id="ibu" class="input2"/>
					</td>
				</tr>
				<tr>
					<td>No. KITAS</td>
					<td>
						<input name="kitas" type="text" id="kitas" class="input2"/>
					</td>
					<td>Status</td>
					<td>
						<select name="miskin" type="text" id="miskin" class="input2">
							<option value=''> - - Pilih Status - - </option>
							<option value='Y'>Miskin</option>
							<option value='N'>Tidak Miskin</option>
						</select>
					</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td><input name="submit" type="submit" class="button" value="Simpan" /></td>
				</tr>
			</table>                
		</form>
<?php
	}
?>